﻿@model IEnumerable<Guan.CMS.Model.Dto.ProductCategoryDto>
@{
    Layout = null;
    var categoryList = ViewBag.CategoryList as int[];
}
@foreach (var item in Model)
{
    if (item.ChildrenNodes!=null && item.ChildrenNodes.Any())
    {
        <fieldset style="border:1px solid black;padding:4px 10px;margin:1em 0;">
            <legend><input type="checkbox" name="categoryId" id="productCategory_@(item.Id)"@(categoryList.Contains(item.Id)?" checked=\"checked\"":"") value="@item.Id" />
        <label for="productCategory_@(item.Id)">@item.Name</label></legend>
            @foreach (var sub in item.ChildrenNodes)
            {
                <input type="checkbox" name="categoryId" id="productCategory_@(sub.Id)"@(categoryList.Contains(sub.Id)?" checked=\"checked\"":"") value="@sub.Id" />
                <label for="productCategory_@(sub.Id)">@sub.Name</label>
            }
        </fieldset>
    }
    else
    {
        <input type="checkbox" name="categoryId" id="productCategory_@(item.Id)"@(categoryList.Contains(item.Id)?" checked=\"checked\"":"") value="@item.Id" />
        <label for="productCategory_@(item.Id)">@item.Name</label>
    }
}